﻿<Controls:MetroWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns:local="clr-namespace:ChoEazyCopy"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    x:Class="ChoEazyCopy.MainWindow"
    Title="Eazy Copy - Cinchoo Inc."
    Height="505"
    Width="798"
    MinHeight="505"
    MinWidth="700"
    AllowDrop="True"
    Closed="Window_Closed"
    x:Name="MyWindow"
    BorderBrush="{DynamicResource AccentColorBrush}"
    BorderThickness="1"
    TitleCaps="False"
    ResizeMode="CanResizeWithGrip"
    Loaded="MyWindow_Loaded" Icon="App.ico" Closing="Window_Closing" ContentRendered="MyWindow_ContentRendered">
    <Window.Resources>
        <ContextMenu x:Key="TextBoxContextMenu" Background="White">
            <MenuItem Command="ApplicationCommands.Copy">
                <MenuItem.Icon>
                    <Image Source="Resources/Copy.png" />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Command="ApplicationCommands.Cut" >
                <MenuItem.Icon>
                    <Image Source="Resources/Cut.png" />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Command="ApplicationCommands.Paste" >
                <MenuItem.Icon>
                    <Image Source="Resources/Paste.png" />
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="ContextMenu" Value="{StaticResource TextBoxContextMenu}" />
        </Style>
        <Style TargetType="{x:Type Button}">
            <Style.Resources>
                <Style TargetType="{x:Type Image}">
                    <Style.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.5" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Style.Resources>
        </Style>
        <Style x:Key="WaterMarkTextBoxStyle" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Grid>
                            <Border x:Name="Bd" SnapsToDevicePixels="True" 
          Background="{TemplateBinding Background}" 
          BorderBrush="{TemplateBinding BorderBrush}"
          BorderThickness="{TemplateBinding BorderThickness}" >
                                <Grid>
                                    <ScrollViewer x:Name="PART_ContentHost"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                    <TextBlock x:Name="textBlock"
                               Opacity="0.5"
                               Text="{TemplateBinding Tag}"
                               Padding="2,0,0,0"
                               TextWrapping="Wrap"
                               Visibility="Hidden" />
                                </Grid>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="Text"
                                       Value="" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Visibility"
                                TargetName="textBlock"
                                Value="Visible" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style
            TargetType="{x:Type TextBlock}"
            x:Key="StatusBarTextBlock">
            <Setter
                Property="TextWrapping"
                Value="NoWrap" />
            <Setter
                Property="TextTrimming"
                Value="CharacterEllipsis" />
            <Setter
                Property="Padding"
                Value="2,0" />
        </Style>
        <local:BoolInverterConverter x:Key="BoolInverterConverter1"/>
        <local:BoolInverterConverter x:Key="BoolInverterConverter2"/>
    </Window.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="70*" MinWidth="400" />
            <ColumnDefinition Width="3" />
            <ColumnDefinition Width="30*" MinWidth="250" />
        </Grid.ColumnDefinitions>

        <ToolBarTray Grid.Row="0" Grid.Column="0" Width="Auto">
            <ToolBarTray.Background>
                <SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}"/>
            </ToolBarTray.Background>
            <ToolBar x:Name="tbrMain" ToolBarTray.IsLocked="True" ToolBar.OverflowMode="Never" Loaded="tbrMain_Loaded" HorizontalAlignment="Left" 
                     Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToolBarTray}}}">
                <ToolBar.Background>
                    <SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}"/>
                </ToolBar.Background>
                <Button x:Name="btnNewFile" Click="btnNewFile_Click" ToolTip="New settings file" IsTabStop="False">
                    <Image Source="Resources/NewFile.png" >
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Opacity" Value="0.5" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button x:Name="btnOpenFile" Click="btnOpenFile_Click" ToolTip="Open settings file" IsTabStop="False">
                    <Image Source="Resources/OpenFile.png" >
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Opacity" Value="0.5" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button x:Name="btnSaveFile" Click="btnSaveFile_Click" ToolTip="Save settings file" IsTabStop="False">
                    <Image Source="Resources/SaveFile.png" >
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Opacity" Value="0.5" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button x:Name="btnSaveAsFile" Click="btnSaveAsFile_Click" ToolTip="Save settings to new file" IsTabStop="False">
                    <Image Source="Resources/SaveAsFile.png" >
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Opacity" Value="0.5" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" IsTabStop="False" />
                <Button x:Name="btnRun" Click="btnRun_Click" ToolTip="Start processing files" IsTabStop="False">
                    <Image Source="Resources/Run.png" >
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Opacity" Value="0.5" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button x:Name="btnStop" IsEnabled="False" Click="btnStop_Click" ToolTip="Stop the processing files" IsTabStop="False">
                    <Image Source="Resources/Stop.png" >
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Opacity" Value="0.5" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Button x:Name="btnClear" IsEnabled="False" Click="btnClear_Click" ToolTip="Clear the status window" IsTabStop="False">
                    <Image Source="Resources/Erase.png" >
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Opacity" Value="0.5" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Button>
                <Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" IsTabStop="False" />
                <local:ChoDonateButton x:Name="btnDonate" 
                                       PaypalAccountEmail="cinchoofrx@gmail.com">
                </local:ChoDonateButton>
                <Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" IsTabStop="False" />
                <TextBlock x:Name="tbSpace" xml:space="preserve" FontSize="16" FontWeight="Bold" Foreground="DarkBlue"
                           Width="Auto" TextAlignment="Right"/>
                <TextBlock x:Name="tbSettingsName" FontSize="16" FontWeight="Bold" Foreground="DarkBlue"
                           Width="Auto" VerticalAlignment="Center" FontFamily="Verdana"/>
            </ToolBar>
        </ToolBarTray>
        <DockPanel Grid.Row="1" Grid.Column="0"
        HorizontalAlignment="Stretch"
        x:Name="dockPanel1"
        VerticalAlignment="Stretch"
        LastChildFill="True"
        FocusManager.FocusedElement="{Binding ElementName=txtFolder}">
            <Grid
            Width="Auto"
            DockPanel.Dock="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <GroupBox
                    x:Name="grpFolders"
                Margin="5"
                Height="Auto"
                Grid.Column="0"
                Header="Choose Folders">
                    <Grid
                    Width="Auto"
                    Height="Auto"
                        >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="35*" />
                            <ColumnDefinition Width="145*"/>
                            <ColumnDefinition Width="368*"/>
                            <ColumnDefinition Width="20" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBox 
                        x:Name="txtSourceDirectory"
                        VerticalAlignment="Stretch"
                        Grid.Row="0"
                        Grid.Column="0"
                        Margin="1"
                        TabIndex="0" Grid.ColumnSpan="3" 
                        Style="{StaticResource WaterMarkTextBoxStyle}" 
                        Tag="Choose source directory..."
                        ToolTip="Choose source directory..."
                            Text="{Binding Path=SourceDirectory, UpdateSourceTrigger=PropertyChanged}"
                        />
                        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                        Grid.Row="0"
                        Grid.Column="3"
                        Margin="1,0,1,2"
                        x:Name="btnSourceDirBrowse"
                        Click="btnSourceDirBrowse_Click"
                        TabIndex="1" ToolTip="Choose source directory..." VerticalAlignment="Bottom">
                            <Image Source="Resources/OpenFolder.png" >
                                <Image.Style>
                                    <Style TargetType="{x:Type Image}">
                                        <Style.Triggers>
                                            <Trigger Property="IsEnabled" Value="False">
                                                <Setter Property="Opacity" Value="0.5" />
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                        </Button>
                        <TextBox
                        x:Name="txtDestDirectory" 
                        Grid.Row="1" 
                        Grid.Column="0"
                        Margin="1"
                        TabIndex="2" Grid.ColumnSpan="3" 
                        Style="{StaticResource WaterMarkTextBoxStyle}"
                        Tag="Choose destination directory..."
                        ToolTip="Choose destination directory..."
                            Text="{Binding Path=DestDirectory, UpdateSourceTrigger=PropertyChanged}"
                            />
                        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                        Grid.Row="1"
                        Grid.Column="3"
                        Margin="1,2,1,1"
                        x:Name="btnDestDirBrowse"
                        TabIndex="3" ToolTip="Choose destination directory..."
                                Click="btnDestDirBrowse_Click" >
                            <Image Source="Resources/OpenFolder.png" >
                                <Image.Style>
                                    <Style TargetType="{x:Type Image}">
                                        <Style.Triggers>
                                            <Trigger Property="IsEnabled" Value="False">
                                                <Setter Property="Opacity" Value="0.5" />
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                        </Button>
                    </Grid>
                </GroupBox>
            </Grid>
            <Grid
            Width="Auto">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition
                    Height="100"
                    MinHeight="100" />
                    <RowDefinition
                    Height="Auto" />
                    <RowDefinition
                    Height="*"
                    MinHeight="100" />
                </Grid.RowDefinitions>
                <GroupBox
                Margin="5,0,5,0"
                Grid.Row="0"
                Header="RoboCopy Command"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch">
                    <TextBox
                    Margin="0,3,0,2"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    Name="txtRoboCopyCmd"
                    TabIndex="24" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" IsReadOnly="True" TextChanged="txtRoboCopyCmd_TextChanged" />
                </GroupBox>
                <GridSplitter
                Margin="5,5,5,0"
                ResizeDirection="Rows"
                Grid.Row="1"
                Height="1"
                HorizontalAlignment="Stretch" IsTabStop="False" />
                <GroupBox
                Margin="5,0,5,5"
                Grid.Row="2"
                Header="Output"
                VerticalAlignment="Stretch">
                    <TextBox
                    Margin="0,3,0,2"
                    VerticalAlignment="Stretch"
                    x:Name="txtStatus"
                    IsReadOnly="True"
                    TabIndex="25" FontFamily="Courier New" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
                </GroupBox>
            </Grid>
        </DockPanel>
        <GridSplitter Grid.Column="1" Grid.RowSpan="2" Width="3" HorizontalAlignment="Right" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" IsTabStop="False" ResizeDirection="Columns" />
        <xctk:PropertyGrid Grid.Column="2" Grid.RowSpan="2" Margin="5" VerticalAlignment="Stretch" Name="pgAppSettings" SelectedObject="{Binding}" SelectedObjectName="" ShowTitle="False" />
        <StatusBar Grid.Row="2" Grid.ColumnSpan="3"
            Margin="5,0,5,5"
            Width="Auto">
            <StatusBarItem
                VerticalContentAlignment="Top"
                Focusable="False"
                Padding="0">
                <TextBlock
                    Style="{StaticResource StatusBarTextBlock}"
                    x:Name="sbAppStatus"><Run Text="Ready"/></TextBlock>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Controls:MetroWindow>
